package com.goktech.olala.core.service.impl;

import com.goktech.olala.core.service.ICtmInfoService;
import com.goktech.olala.server.dao.customer.CustomerInfoMapper;
import com.goktech.olala.server.dao.customer.UserLoginLogMapper;
import com.goktech.olala.server.dao.customer.UserLoginMapper;
import com.goktech.olala.server.pojo.customer.CustomerInfo;
import com.goktech.olala.server.pojo.customer.UserLogin;
import com.goktech.olala.server.pojo.customer.UserLoginLog;
import com.goktech.olala.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Classname CtmInfoServiceImpl
 * @Description TODO
 * @Date 2020/12/26 15:36
 * @Created by wjs
 */
@Service
public class CtmInfoServiceImpl implements ICtmInfoService {
    @Autowired
    UserLoginMapper userLoginMapper;

    @Autowired
    UserLoginLogMapper userLoginLogMapper;

    @Autowired
    CustomerInfoMapper customerInfoMapper;

    @Override
    public UserLogin selectUser(String userName, String password) {
        //密码加密
        String password1 = MD5Util.md5(password);
        //查询
        UserLogin userLogin1 = userLoginMapper.LoginSelect(userName, password1);
        return  userLogin1;
    }

    @Override
    public void addLoginLog(UserLoginLog userLoginLog) {
        userLoginLogMapper.insert(userLoginLog);
        return;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int updateUserLogin(UserLogin userLogin) {
        return userLoginMapper.update(userLogin);
    }

    @Override
    public List<CustomerInfo> selectCustomerInfo() {
        return customerInfoMapper.selectAll();
    }

    @Override
    public UserLogin registerSelect(String userName) {
        return userLoginMapper.registerSelect(userName);
    }

    @Override
    public int register(UserLogin userLogin) {
        return userLoginMapper.insert(userLogin);
    }
}
